package com.wcarmon.life.command{

    import com.adobe.cairngorm.commands.ICommand
    import com.adobe.cairngorm.control.CairngormEvent;
	import mx.controls.Alert;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.IResponder;
	import com.wcarmon.life.model.LifeModelLocator;
	import com.wcarmon.life.event.*;
	import com.wcarmon.life.vo.*;
	import com.wcarmon.life.business.*;
	import mx.utils.ObjectUtil;

	public class ShowOrganizeZoomCommand implements ICommand, IResponder {
		include "../../includes/loggerSnippet.as";
		
		public function execute( event : CairngormEvent ) : void {
			var e : ShowOrganizeZoomEvent = ShowOrganizeZoomEvent( event );
			var delegate : ZoomDelegate = new ZoomDelegate(this);
			delegate.getBlock( e.blockId );
		}

	 	public function result( event : Object ) : void {
			var e : ResultEvent = ResultEvent(event);
			var model : LifeModelLocator = LifeModelLocator.getInstance();
			//log.debug( "Zoom result: " + ObjectUtil.toString(e) );
			if( null == e.result[0] ){
				log.fatal('Cannot zoom on block');
				log.fatal( 'e.result = ' + e.result );
				return;
			}
			model.currentZoomBlock = BlockVO.makeBlockFromObject( e.result[0] );
			model.gotoScreen( LifeModelLocator.SCREEN_ORGANIZE_ZOOM );
		}

		public function fault( event : Object ) : void {
			include "includes/FaultSnippet.as";
		}
	}
}